﻿using System;
using System.IO;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Collections;
using MySql.Data.MySqlClient;
using gp_class;
using generic_class;
using data_adapter;
using AcadApp = Autodesk.AutoCAD.ApplicationServices.Application;
using Autodesk.AutoCAD.ApplicationServices;

namespace pallete_main
{
    public partial class MainForm : UserControl
    {
      //  String m_strGrapicsDirectory = "c:\\cad";
            
        public MainForm()
        {
            InitializeComponent();
        }
  
        private void ModelessForm_Load(object sender, EventArgs e)
        {

            TreeViewControl treeView = new TreeViewControl();
            TabPage page = new TabPage();
            tabControl1.Size = new Size(this.ClientSize.Width, this.ClientSize.Height - 20);
            page.Size = tabControl1.ClientSize;
            page.Name = "page1";
            page.Text = "工程1";

            treeView.Dock = DockStyle.Fill;
            treeView.Size = new Size(this.ClientSize.Width, this.ClientSize.Height - 20); ;
            page.Controls.Add(treeView);
            tabControl1.Controls.Add(page);

       //     test3();

        }

        private void test3()
        {

            DataAdapter adap = new DataAdapter();
            DataTable tbl = adap.GetDataTable("select  deviceIn,deviceOut from devicelink_table where deviceOut in (731,734)");

            module_layout layout = new module_layout();
            ArrayList lstLine = new ArrayList();
            _line_item item = new _line_item();
            item.start_type = _device_type.DT_OTHER;
            item.end_type = _device_type.DT_OTHER;
            item.nStartDevice = 0;
            item.nEndDevice = 1;
            lstLine.Add(item);

            item = new _line_item();
            item.start_type = _device_type.DT_OTHER;
            item.end_type = _device_type.DT_OTHER;
            item.nStartDevice = 0;
            item.nEndDevice = 3;
            lstLine.Add(item);

            item = new _line_item();
            item.start_type = _device_type.DT_OTHER;
            item.end_type = _device_type.DT_OTHER;
            item.nStartDevice = 3;
            item.nEndDevice = 8;
            lstLine.Add(item);

            item = new _line_item();
            item.start_type = _device_type.DT_OTHER;
            item.end_type = _device_type.DT_OTHER;
            item.nStartDevice = 2;
            item.nEndDevice = 8;
            lstLine.Add(item);

            //im
            item = new _line_item();
            item.start_type = _device_type.DT_IM;
            item.end_type = _device_type.DT_IM;
            item.nStartDevice = 0;
            item.nEndDevice = 3;
            lstLine.Add(item);

            item = new _line_item();
            item.start_type = _device_type.DT_IM;
            item.end_type = _device_type.DT_IM;
            item.nStartDevice = 3;
            item.nEndDevice = 4;
            lstLine.Add(item);

            item = new _line_item();
            item.start_type = _device_type.DT_IM;
            item.end_type = _device_type.DT_ROUTER;
            item.nStartDevice = 0;
            item.nEndDevice = 4;
            lstLine.Add(item);

            item = new _line_item();
            item.start_type = _device_type.DT_IM;
            item.end_type = _device_type.DT_ROUTER;
            item.nStartDevice = 2;
            item.nEndDevice = 4;
            lstLine.Add(item);

            //other to router
            item = new _line_item();
            item.start_type = _device_type.DT_OTHER;
            item.end_type = _device_type.DT_ROUTER;
            item.nStartDevice = 0;
            item.nEndDevice = 4;
            lstLine.Add(item);

            item = new _line_item();
            item.start_type = _device_type.DT_OTHER;
            item.end_type = _device_type.DT_ROUTER;
            item.nStartDevice = 3;
            item.nEndDevice = 4;
            lstLine.Add(item);

            item = new _line_item();
            item.start_type = _device_type.DT_OTHER;
            item.end_type = _device_type.DT_ROUTER;
            item.nStartDevice = 8;
            item.nEndDevice = 4;
            lstLine.Add(item);

            item = new _line_item();
            item.start_type = _device_type.DT_IM;
            item.end_type = _device_type.DT_OTHER;
            item.nStartDevice = 4;
            item.nEndDevice = 7;
            lstLine.Add(item);


            item = new _line_item();
            item.start_type = _device_type.DT_IM;
            item.end_type = _device_type.DT_OTHER;
            item.nStartDevice = 1;
            item.nEndDevice = 7;
            lstLine.Add(item);

            item = new _line_item();
            item.start_type = _device_type.DT_IM;
            item.end_type = _device_type.DT_OTHER;
            item.nStartDevice = 2;
            item.nEndDevice = 4;
            lstLine.Add(item);
            layout.DrawLines(lstLine);
        }

        private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        private void MainForm_Resize(object sender, EventArgs e)
        {
            tabControl1.Size = new Size(this.ClientSize.Width,this.ClientSize.Height - 10);
            if (tabControl1.TabCount > 0)
            {
                TabPage page = tabControl1.SelectedTab;
                page.Size = new Size(this.ClientSize.Width, this.ClientSize.Height - 20);
            }
            this.ResumeLayout(true);
        }

        private void tabControl1_Resize(object sender, EventArgs e)
        {

        }

    }
}
